import {track, trigger} from ".";
const get = createGetter();
const set = createSetter();

function createGetter() {
  return function getter(target: object, key: string | symbol, receiver: any) {
    const val = Reflect.get(target, key, receiver);
    track(target, key);
    return val;
  };
}

function createSetter() {
  return function setter(
    target: object,
    key: string | symbol,
    val: any,
    receive: any,
  ) {
    Reflect.set(target, key, val, receive);
    trigger(target, key);
    return val;
  };
}
export const mutableHandles = {
  get,
  set,
};
